package com.scau.data.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.scau.data.entity.CommodityInfoDO;
import com.scau.database.entity.stockbuyer.SearchCommodityVO;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface CommodityInfoMapper extends BaseMapper<CommodityInfoDO> {
    /**
     *
     * @param index 必须是%str%
     * @return
     */
    @Results(id = "commodityInfoVOMap",value = {
            @Result(property = "bar_code",column = "bar_code"),
            @Result(property = "recommend_price",column = "recommend_price"),
            @Result(property = "max_price",column = "max_price"),
            @Result(property = "min_price",column = "min_price"),
            @Result(property = "limit_buy",column = "limit_buy"),
            @Result(property = "repair_days",column = "repair_days"),
            @Result(property = "return_days",column = "return_days"),
            @Result(property = "exchange_days",column = "exchange_days"),
    })
    @Select("select * from commodity_info " +
            "where bar_code like #{index} or " +
            "name like #{index} or " +
            "brand like #{index}")
    public List<SearchCommodityVO> getSearchCommodities(@Param("index") String index);

    @Select("select * from commodity_info where bar_code =#{barCode}")
    public List<CommodityInfoDO> getCommodityInfoByBarCode(String barCode);
}
